package com.example.wtt.controller;

import com.example.wtt.common.Result;
import com.example.wtt.controller.dto.UpvoteDTO;
import com.example.wtt.entity.Comments;
import com.example.wtt.entity.User;
import com.example.wtt.service.CommentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/comments") // 统一给接口加前缀
public class CommentsController {
    @Autowired
    private CommentsService commentsService;

    @GetMapping("/queryComment/{dynamicId}")
    public Result queryComment(@PathVariable Integer dynamicId){
        return Result.success(commentsService.queryComment(dynamicId));
    }

    @GetMapping("/commentDetail/{dynamicId}")
    public Result commentDetail(@PathVariable Integer dynamicId){
        return Result.success(commentsService.commentDetail(dynamicId));
    }

    @PostMapping("/publishComment")
    public Result publishComment(@RequestBody Comments comment){
        return Result.success(commentsService.saveOrUpdate(comment));
    }
}
